home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / probots.arc / M66.PR < prev    next >
Text File  |  1991-04-28  |  2KB  |  78 lines

  1.  
  2.  
  3.   PROCEDURE M66;
  4.     { Based on C-Robot M66 : programmed by OBI-ONE }
  5.  
  6.   VAR
  7.     drv_dir        : Integer; { drive direction }
  8.     scn_dir        : Integer; { scan direction }
  9.     step           : Integer; { scan step }
  10.     degs           : Integer; { half of scan step }
  11.     Range          : ARRAY[-2..2] OF Integer; { range to oponent }
  12.     range_sv       : Integer; { range of last scan }
  13.     found          : Boolean; { foe found ? }
  14.     x, y           : Integer;
  15.  
  16.     PROCEDURE Move;
  17.     BEGIN
  18.       x := loc_x;
  19.       y := loc_y;
  20.       IF (x < 200)
  21.       THEN drv_dir := Random(45)
  22.       ELSE IF (x > 800) THEN drv_dir := Random(45)+180;
  23.  
  24.       IF (y < 200)
  25.       THEN drv_dir := Random(45)+90
  26.       ELSE IF (y > 800) THEN drv_dir := Random(45)+270;
  27.  
  28.       drive(drv_dir, 100);
  29.     END; {Move}
  30.  
  31.     PROCEDURE attack;
  32.     VAR I, Pick    : Integer;
  33.     BEGIN
  34.       cannon(scn_dir, range_sv); {shoot at last foe postion}
  35.       Pick := 99;
  36.       FOR I := -2 TO 2 DO
  37.         BEGIN
  38.           Range[I] := scan(scn_dir+step*I, degs);
  39.           IF Range[I] > 40 THEN
  40.             BEGIN
  41.               Pick := I;
  42.               I := 2;
  43.             END;
  44.         END;
  45.       IF Pick <> 99 THEN
  46.         BEGIN
  47.           found := True;
  48.           range_sv := Range[Pick];
  49.           scn_dir := scn_dir+step*Pick;
  50.           cannon(scn_dir, range_sv);
  51.         END
  52.       ELSE scn_dir := scn_dir+120;
  53.     END; {Attack}
  54.  
  55.   BEGIN {M66 Main}
  56.     drv_dir := Random(360); { initialize }
  57.     scn_dir := drv_dir+120;
  58.     found := False;
  59.     range_sv := 700;
  60.     step := 20;
  61.     degs := step DIV 2;
  62.  
  63.     REPEAT { main loop }
  64.  
  65.       { drive at full speed.                       }
  66.       { when close to wall, turn around at random. }
  67.  
  68.       Move;
  69.  
  70.       { scan every 20 degrees resolution. }
  71.       { if you find a foe, then attack it with your cannon. }
  72.  
  73.       attack;
  74.  
  75.     UNTIL Dead OR Winner; { end of main loop }
  76.  
  77.   END; {M66 Main}
  78.